import store from '@/store'

const formatDate = function ( time = new Date(), str){
       let date = new Date(time);
       let year = date.getFullYear();
       let month = date.getMonth() + 1;
       let day = date.getDate();
       let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
       let minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
       let second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
       month >= 1 && month <= 9 ? (month = "0" + month) : "";
       day >= 0 && day <= 9 ? (day = "0" + day) : "";
       var timer;
      if (str == 'yyyy-MM-dd HH:mm:ss') {
      	 timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
      }else if(str == 'yyyy-MM-dd') {
      	 timer = year + '-' + month + '-' + day;
      }else if(str == 'yyyy年MM月dd'){
      	 timer = year + '年' + month + '月' + day + '日';
      }else if(str == 'yyyy'){
        timer = year;
      }
	  // console.log('========')
	  // console.log(time,str)
       return timer
}

// const showButton = async function(code) {
//      const buttons = await store.getters.buttons
//      buttons.
// }

const xxx = function (a){
	a='xxxx'
	return a
}
export {
    formatDate,
	xxx
}
